#include<bits/stdc++.h>
using namespace std;
const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
map<pair<int,int>,int>cnt;
int main()
{
	freopen("grid.in","r",stdin);
	freopen("grid.out","w",stdout);
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	queue<pair<int,int> >q;
	for(int i=1;i<=k;i++)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		cnt[{x,y}]=2;
		q.push({x,y});
	}
	int ans=0;
	while(q.size())
	{
		pair<int,int>u=q.front();
		q.pop();
		ans++;
		for(int i=0;i<4;i++)
		{
			pair<int,int>v={u.first+dx[i],u.second+dy[i]};
			if(v.first>n||v.second>m||!v.first||!v.second)
				continue;
			cnt[v]++;
			if(cnt[v]==2)
				q.push(v);
		}
	}
	printf("%d",ans);
	return 0;
}
